<?php

namespace App\Model;

use Hyperf\DbConnection\Model\Model;

/**
 * 用户充值黑名单
 */
class UserPayBlacklist extends Model
{
    protected $table = 'user_pay_blacklist';
    protected $fillable = ['user_id', 'flag'];

    static function getList()
    {
        return self::where('flag', 1)->pluck('user_id')->toArray();
    }

    static function checkExclude($userId = 0)
    {
        return in_array($userId, self::getList());
    }

    static function addUser($userId = 0)
    {
        return self::updateOrCreate([
            'user_id' => $userId
        ], [
            'user_id' => $userId,
            'flag' => 1
        ]);
    }
}
